import java.util.Scanner;

public class phoneTest {
    public static void main(String[] args) {
        // 创建一个数组来存储手机对象
        phone[] phones = new phone[3];
        Scanner sc = new Scanner(System.in);
        //键盘录入手机的信息
        for(int i = 0;i < phones.length;i++){
            //创建对象
            phone p = new phone();
            //键盘录入
            System.out.println("输入手机名：");
            String name = sc.next();
            System.out.println("输入手机价格：");
            int price = sc.nextInt();
            System.out.println("输入手机颜色：");
            String color = sc.next();
            phone phone = new phone(name,price,color);
            phones[i] = phone;
        }
        //遍历数组
        for(int i = 0;i < phones.length;i++){
            phone p = phones[i];
            System.out.println(p.getName() + "," + p.getPrice() + "," + p.getColor());
        }
        int sum = 0;
        for(int i = 0;i < phones.length;i++){
            phone price = phones[i];
           sum += price.getPrice();
        }
        int avg = sum / phones.length;
        System.out.println("平均价格为：" + avg);
    }
}
